
#ifndef __HTTP_SERVER_H
#define __HTTP_SERVER_H

#include <apr-1/apr.h>
#include "TCPServer.h"

#define MAX_HEADERS 10

class HTTPServer : public TCPServer
{
   public:
      HTTPServer(int inoofthreads, int iportno, const char *ihostname, apr_pool_t *upperpool) :
         TCPServer(inoofthreads, iportno, ihostname, upperpool) {}
      ~HTTPServer() {}
      apr_table_t *GetTable(int i, apr_pool_t *mp, apr_size_t clength, const char *separator, const char *eol);
      apr_table_t *GetHeaders(int i, apr_pool_t *mp);
      apr_table_t *GetPOSTData(int i, apr_pool_t *mp, apr_size_t clength);
      apr_size_t GetContentLength(apr_table_t *htable);
      int ServeFilesFromWhiteList(apr_table_t *htable, int i, apr_pool_t *mp, const char **fileswhitelist);
      void ReplyWithSentence(int i, apr_pool_t *mp, const char *body);
      void RedirectAfterPOST(int i, apr_pool_t *mp, const char *relocation);
      void IncrementUnlock(int i);
      void Error404(int i);
      void GETSession(int i, apr_pool_t *mp);
      void POSTSession(int i, apr_pool_t *mp);
      static void *ClientHandler(apr_thread_t *tthread, void *args);
      virtual functor GetClientHandlerFunction() const { return (functor)(&ClientHandler); }
};

#endif
